#include <algorithm>
#include <cstdio>
using namespace std;

int n, a[20010];
int ans;
bool flag;
int main() {
	freopen("wing.in", "r", stdin);
	freopen("wing.out", "w", stdout);
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		ans = max(a[i] + a[i - 1], ans);
	}
	ans = max(ans, a[1] + a[n]);
	printf("%d", ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}